import type { KnowledgeDetail, KnowledgeCardKeyPointsEntity } from '@/types'
import { http } from '@/utils/http'
import { getBusinessApiPrefix } from '@/utils/config'

/**
 * 根据技术栈ID获取知识卡片列表
 */
export const getKnowledgeCardsByTechCodeAPI = (techCode : string) => {
	return http<KnowledgeDetail[]>({
		url: `${getBusinessApiPrefix()}/knowledge-cards/getKnowledgeCardsByTechCodeAPI`,
		method: 'POST',
		data: { techCode },
	})
}

/**
 * 根据技术栈ID和分类ID获取知识卡片列表
 */
export const getKnowledgeCardsByTechAndCategoryAPI = (techCode : string, categoryCode : string) => {
	return http<KnowledgeDetail[]>({
		url: `${getBusinessApiPrefix()}/knowledge-cards/getKnowledgeCardsByTechAndCategoryAPI`,
		method: 'POST',
		data: { techCode, categoryCode },
	})
}




/**
 * 根据技术栈Code和ID获取知识卡片
 */
export const getKnowledgeDetailByTechCodeAndIdAPI = (techCode : string, id : number) => {
	return http<KnowledgeDetail>({
		url: `${getBusinessApiPrefix()}/knowledge-cards/getKnowledgeDetailByTechCodeAndIdAPI`,
		method: 'POST',
		data: { techCode, id },
	})
}

/**
 * 根据知识卡片ID获取要点列表
 */
export const getKnowledgeCardKeyPointsAPI = (knowledgeCardId : number) => {
	return http<KnowledgeCardKeyPointsEntity[]>({
		url: `${getBusinessApiPrefix()}/knowledge-cards/getKnowledgeCardKeyPointsAPI`,
		method: 'POST',
		data: { knowledgeCardId },
	})
}

/**
 * 根据知识卡片ID获取知识卡片基本信息
 */
export const getKnowledgeCardByIdAPI = (id : number) => {
	return http<KnowledgeDetail>({
		url: `${getBusinessApiPrefix()}/knowledge-cards/getKnowledgeCardByIdAPI`,
		method: 'POST',
		data: { id },
	})
}